package com.mooc.fuxi.imgload;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.mooc.fuxi.R;

import jp.wasabeef.glide.transformations.CropCircleTransformation;

public class ImageLoad {

    private ImageLoad(){}

    private volatile static ImageLoad instance;

    public static ImageLoad getInstance() {
        if (instance == null){
            synchronized (ImageLoad.class){
                if (instance == null)
                    instance = new ImageLoad();
            }
        }
        return instance;
    }

    //加载填充满控件图片
    public void loadMatchImg(String url, ImageView img){
        Glide.with(img.getContext()).load(url).centerCrop()
                .error(R.drawable.ic_launcher_background)
                .into(img);
    }
    //加载圆形图片
    public void loadCircleImg(String url,ImageView img){
        Glide.with(img.getContext()).load(url)
                .transform(new CropCircleTransformation())
                .into(img);
    }

}
